import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    cityName: '定位中...'
  },
  mutations: {

    /**
     * 更新store
     * 使用方法 例：
     * this.$store.update({ 'cityName': '北京' });
     *
     * @param {*} state
     * @param {*} payload
     */
    update (state, payload) {
      Object.keys(payload).map(item => {
        state[item] = payload[item];
      });
    }
  }
});
export default store;
